<?php
function success_flag($cook_uid) {
	global $_REG,$db,$_ZEAI,$navarr,$SHALOU_ARR,$_VIP;
	$cook_uid=intval($cook_uid);
	$row = $db->ROW(__TBL_USER__,"nickname,grade,loveb,tguid","flag=2 AND id=".$cook_uid);
	if ($row){
		$grade=$row['grade'];
		$loveb=$row['loveb'];
		$tguid=$row['tguid'];
		$nickname=trimhtml(dataIO($row['nickname'],'out'));
	}else{
		return false;
	}
	$switch = json_decode($_ZEAI['switch'],true);
	$TG_set = json_decode($_REG['TG_set'],true);
	$reg_loveb = abs(intval($_REG['reg_loveb']));
	$reg_flag  = ($_REG['reg_flag']==1)?1:0;
	$dataflag  = ($switch['sh']['moddata_'.$grade] == 1)?1:0;
	//
	$photoMflag = intval($switch['sh']['photom_'.$grade]);
	$photoMflag = ($photoMflag == 1)?1:0;
	//
	if($dataflag==1 && is_array($SHALOU_ARR) && count($SHALOU_ARR)>0){
		$SQLli="";
		foreach ($SHALOU_ARR as $k=>$V){
			if($k!='photo_s'&& !empty($V) )$SQLli.=",".$k."='".$V."'";
		}
	}
	//新头像处理
	if(!empty($SHALOU_ARR['photo_s'])){
		if($photoMflag==1){
			$photo_s = $SHALOU_ARR['photo_s'];
			$_s=u_pic_reTmpDir_send($photo_s,'m');
			u_pic_reTmpDir_send(smb($photo_s,'m'),'m');
			u_pic_reTmpDir_send(smb($photo_s,'b'),'m');
			u_pic_reTmpDir_send(smb($photo_s,'blur'),'m');
			$db->query("UPDATE ".__TBL_USER__." SET photo_s='".$_s."',photo_f=1 WHERE id=".$cook_uid);
			$db->query("UPDATE ".__TBL_SHALOU__." SET photo_f=1 WHERE uid=".$cook_uid);
			$SHALOU_ARR['photo_s']=$_s;
		}else{
			$db->query("UPDATE ".__TBL_SHALOU__." SET photo_f=0 WHERE uid=".$cook_uid);
		}
	}
	/* 清单通知 */
	if ($reg_loveb > 0 && $loveb == 0){
		$SQLli.=",loveb=".$reg_loveb;
		//清单
		$db->AddLovebRmbList($cook_uid,'新用户注册',$reg_loveb,'loveb',6);		
		//站内消息
		$C = $uname.'您好，您有一笔'.$_ZEAI['loveB'].'到账！　　<a href='.Href('loveb').' class=aQING>查看详情</a>';
		$db->SendTip($cook_uid,'您有一笔'.$_ZEAI['loveB'].'到账！',dataIO($C,'in'),'sys');
	}
	/***crm_qxnum,hh_num***/
	$crm_qxnumARR = json_decode($_VIP['qianxian_num'],true);
	$endnum1=abs(intval($crm_qxnumARR[$grade]));
	if($endnum1>0)$SQLNUM1 = ",crm_qxnum=$endnum1";
	//
	$hh_numARR = json_decode($_VIP['hh_num'],true);
	$endnum2=abs(intval($hh_numARR[$grade]));
	if($endnum2>0)$SQLNUM2 = ",hh_num=$endnum2";
	//
	$rz_numARR = json_decode($_VIP['rz_num'],true);
	$endnum3=abs(intval($rz_numARR[$grade]));
	if($endnum3>0)$SQLNUM3 = ",rz_num=$endnum3";
	//
	$db->query("UPDATE ".__TBL_USER__." SET flag=$reg_flag".$SQLli.$SQLNUM1.$SQLNUM2.$SQLNUM3." WHERE id=".$cook_uid);
	$new_row_shalou=encode_json($SHALOU_ARR);
	$db->query("UPDATE ".__TBL_SHALOU__." SET jsonstr='$new_row_shalou' WHERE uid=".$cook_uid);
	set_data_ed_bfb($cook_uid);
	if(ifint($tguid) && in_array('tg',$navarr))TG($tguid,$cook_uid,'reg');
	//
	$tipadmlist=$_REG['tipadmlist'];
	if(!empty($tipadmlist)){
		$rt=$db->query("SELECT openid FROM ".__TBL_ADMIN__." WHERE id in ($tipadmlist) AND flag=1 AND subscribe=1 AND openid<>''");
		$total = $db->num_rows($rt);
		if ($total > 0) {
			for($i=1;$i<=$total;$i++) {
				$rows = $db->fetch_array($rt,'name');
				if(!$rows) break;
				$openid=$rows['openid'];
				if (!empty($openid)){
					$first     = urlencode('【'.$nickname.' uid:'.$cook_uid.'】新用户注册成功！');
					$keyword1  = '新用户注册';
					$keyword3  = urlencode($_ZEAI['siteName']);
					$remark    = '请过5分钟后（可能正在完善资料中）进入后台进行资料审核。';
					$url = $_ZEAI['adm2'].'/m_login.php';
					@wx_mb_sent('mbbh=ZEAI_ADMIN_INFO&openid='.$openid.'&keyword1='.$keyword1.'&keyword3='.$keyword3.'&time='.ADDTIME.'&first='.$first.'&remark='.$remark.'&url='.$url);
				}
			}
		}	
	}
}
?>